package org.biubiu0002.baiblog.core.validator;


import com.google.common.base.Preconditions;
import org.biubiu0002.baiblog.common.constants.Constants;
import org.biubiu0002.baiblog.core.model.vo.req.RegisterReqVo;

/**
 * @Author: biubiu0002
 * @Date: 2022-05-07 0:12
 **/
public class AuthValidator extends BaseValidator{



    public static void registerValidate(RegisterReqVo registerReqVo){
        checkUsernameValid(registerReqVo.getUsername());
        checkPasswordValid(registerReqVo.getPassword());

    }


    private static void checkUsernameValid(String username){
        Preconditions.checkArgument(username.matches(Constants.USERNAME_REGEX),"用户名输入格式有误");
    }

    private static void checkPasswordValid(String password){
        Preconditions.checkArgument(password.matches(Constants.PASSWORD_REGEX),"密码输入格式有误");

    }

    private static void checkUserPhoneValid(String phone){
        Preconditions.checkArgument(phone.matches(Constants.PHONE_REGEX),"手机号输入格式有误");
    }

    private static void checkUserEmailValid(String email){
        Preconditions.checkArgument(email.matches(Constants.EMAIL_REGEX),"邮箱输入格式有误");
    }

}
